#include<stdio.h>
#include<unistd.h>
#include<stdlib.h>
int main()
{
	pid_t id = fork();
	if(id == 0)
	{
		//子进程
		//int cnt = 5; //休眠5s
		int cnt = 500;
		while(cnt--)
		{
			printf("I am a child,my id is %d; my parent's id is %d\n", getpid(), getppid());
		sleep(1);
		}
		exit(0); //终止程序
	}
	else //不考虑<0 
	{
		//int cnt = 6;
		int cnt = 5;
		//父进程
		while(cnt--)
		{
			printf("I am a father,my id is %d; my parent's id is %d\n", getpid(), getppid());
			sleep(1);
		}
	}
	return 0;
}
